<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <title>全视图BOM展示</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <meta content="0" http-equiv="Expires"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <link rel="stylesheet" href="../styles/base.css"/>
    <link rel="stylesheet" href="../styles/common.css"/>
    <link rel="stylesheet" href="../styles/font/iconfont.css"/>
    <link rel="stylesheet" href="../jqueryNicepage/css/layui.css"  media="all">
    <style>
        body{
            background:#ddecf5;
            min-width: 1200px;
            overflow-y: hidden;
        }
        .seachHeader span{
            margin-top: 5px;
            float: left;
            display: inline-block;
            height:30px;
            line-height: 30px;
            font-size: 16px;

        }
        .seachHeader span:first-child{
            margin-left: 20px;
        }
        .seachHeader .inputBox{
            float:left;
            width:200px;
            height:30px;
            line-height: 30px;
            font-size: 14px;
            padding-left: 10px;
            position: relative;
        }
        .seachHeader .inputBox input{
            width:190px;
            height:30px;
            line-height: 30px;
            position: absolute;
            padding-left: 10px;
            left:0;
        }
        .searchSureBtn{
            margin-left: 30px;
            float:right;
            background-color: #eee;
            font-family: 'Open Sans', sans-serif;
            font-size: 14px;
            text-decoration: none;
            font-weight: 600;
            color: #333;
            position: relative;
            padding: 1px 15px;
            margin-right: 15px;
            margin-top:2px;
            border-top-right-radius: 10px;
            border-bottom-right-radius: 10px;
            border-top-left-radius: 10px;
            border-bottom-left-radius: 10px;
            background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(242,242,242)), color-stop(1, rgb(242,242,242)) );
            cursor: pointer;
            overflow: hidden;
        }
        .searchSureBtn:hover{
            color:#fff;
            background:#40E0D0;
        }
        body .searchContainer{
            position: relative;
            width:96%;
            margin-left: 2%;
            /*margin-top: 10px;*/
            max-height: 98%;
            min-width: 1200px;

        }
        .seachHeader .selectedItem{
            display: none;
        }
        .selectedItemFrom .layui-form{
            width:260px;
            font-size: 14px;
        }
        .layui-table tr td{
            text-align: center;
        }
        .layui-table tr td a{
            float:left;
          /*  min-width:40px;*/
            width:auto;
            text-align: center;
            padding:0 5px;
            white-space:nowrap;
            text-align: center;
            /*color:#0000FF;*/
            /*cursor: pointer;
            text-decoration:underline;*/
        }
        .layui-table tr .td2 span:nth-last-child(1){
            display:none
        }
        .layui-table tr .td1 a{
            width:100%;
            text-align: center;
        }
        .layui-table tr .td2 a{
            width:auto;
            padding:0 5px;
        }
        .layui-table tr td span{
            float:left;
            width:5px;
            text-align: center;
            /*// color:red;*/
        }
        .layui-table tr td a{
            float:left;
            width:40px;
            text-align: center;
            padding:0 0px;
            color:#0000FF;
            cursor: pointer;
            text-decoration:underline;
        }
        .layui-table tr td .noCursor{
            cursor:default;
        }
        .formContent{
            height:auto;
            /*overflow-y: scroll;*/
        }
        .formContent center{
            margin-top:-10px;
        }
        .formContent .layui-table .td0{
            text-align: left;
        }
        .formContent .layui-table .td3{
            text-align: left;
        }
        .formContent center #pageBar2{
            position:absolute;
            bottom:10px;
            width:100%;
            text-align: center;
            display: none;
        }
    </style>
</head>
<body>
<div id="loading">
    <img src='../styles/img/loading.gif' />
</div>
<div class="searchContainer">

    <div class="formContent">
    </div>
</div>
</body>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script src="../js/common/publicClass.js"></script>
<script src="../js/common/myAjax.js"></script>
<script src="../js/common/utils.js"></script>
<!--<script type="text/javascript" src="../js/layui/layui.js"></script>-->
<script src="../layer/layer.js" charset="utf-8"></script>
<script language="Javascript" src="../jqueryNicepage/js/layui.js"></script>
<script>
    searchFn();
 /*   var heightform=$(".searchContainer").height();
    $(".formContent").css("height",heightform*0.90);*/
    function searchFn(){
        var height=document.body.clientHeight;
        var width =document.body.clientWidth;
        $("#loading img").css({
            "margin-left":width/2-25+"px",
            "margin-top":height/2-25+"px"
        })
        var partNumber = getQueryStringByNameTwo("partNumber")!=undefined?getQueryStringByNameTwo("partNumber"):"";
        var view= getQueryStringByNameTwo("view")!=undefined?getQueryStringByNameTwo("view"):"";
        if(partNumber!=""&&view!=""){
            var url = "/AllViewBomDisplayController/queryAllViewBom",
                    data="partNumber="+encodeURIComponent(partNumber)+"&view="+view;
            $("#loading").css({
                display:"block"
            });
            MaterialReverseAjax(url,data,suCallback);

        }else{
            //layerFn("请输入物料编号！");
        }
    }
    function suCallback(str){
        $("#loading").css({
            display:"none"
        });
        if(str.partDate!=undefined&&str.partDate.length>0){
            var dataListObjArr=[];
            for(var i=0;i<str.partDate.length;i++){
                var dataListObj={};
                dataListObj.level=str.partDate[i].level;
                dataListObj.partNumber=str.partDate[i].partNumber+"|"+str.partDate[i].partNumberURL+"{}";

                dataListObj.subPart="";
                for(var m=0;m<str.partDate[i].subPart.length;m++){
                    if(m!=(str.partDate[i].subPart.length/*-1*/)){
                        dataListObj.subPart+=str.partDate[i].subPart[m].number+"|"+str.partDate[i].subPart[m].numberURL+"{}";
                    }else{
                        dataListObj.subPart+=str.partDate[i].subPart[m].number+"|"+str.partDate[i].subPart[m].numberURL;
                    }

                }
                dataListObj.partDescription=str.partDate[i].partDescription;
                dataListObj.partVersion=str.partDate[i].partVersion;
                dataListObj.viewStr="";
                for(var m=0;m<str.partDate[i].viewStr.length;m++){
                   /* if(getQueryStringByNameTwo("partNumber")==str.partDate[i].viewStr[m].number&&getQueryStringByNameTwo("view")==str.partDate[i].viewStr[m].view){
                        str.partDate[i].viewStr[m].number="";
                    }*/
                    if(m!=(str.partDate[i].viewStr.length/*-1*/)){
                        dataListObj.viewStr+=str.partDate[i].viewStr[m].view+"|"+str.partDate[i].viewStr[m].number+"{}";
                    }else{
                        dataListObj.viewStr+=str.partDate[i].viewStr[m].view+"|"+str.partDate[i].viewStr[m].number;
                    }

                }

                //dataListObj.viewStr=str.partDate[i].viewStr;
                dataListObj.partState=str.partDate[i].partState;
                dataListObjArr.push(dataListObj);
            }
            $(".seachHeader .selectedItem").css({
                "display":"block"
            })
            window.historyList1=dataListObjArr;
            window.headers1=["序号","层级","物料编号","替代料编号","描述","最新版本号","产地视图","状态"] //table的列名
            window.widths1=["100","100","200","300","500","200","300","200"]
            $(".formContent").empty().load('./newTable.html',"",function(){
                setTimeout(function(){
                    var heightform=$(".searchContainer").height()-20;

                    if($(".formContent")[0].offsetHeight>(heightform*0.85)){
                        $("#pageBar2").css("top",heightform*0.85+20)
                    }else{
                        $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+80);
                    }
                    $("#pageBar2").css("display","block")
                    $(".formContent").css({
                        "max-height":heightform*0.85,
                        "overflow-y":"scroll"
                    });
                    clearTimeout();
                },200)
            });
        }else{
            layerFn("您查询的数据不存在！");
        }
    }
    $(document).unbind().on("click",".layui-table tr .td5 a",function(){
        var url="/AllViewBomDisplayController/queryChildren";
        var view=$(this).text()!=undefined&&$(this).text()!=""?$(this).text():"";
        var number=$(this).attr("data-num")!=undefined&&$(this).attr("data-num")!=""?$(this).attr("data-num"):"";
        if(view!=""&&number!=""){
            var data="partNumber="+encodeURIComponent(number)+"&view="+view
            MaterialReverseAjax(url,data,function(str){
                var success=str.sucess!=undefined&&str.sucess!=""?str.sucess:"";
                if(success!=""&&success=="true"){
                    window.open("allBomTow.html?partNumber="+number+"&view="+view)
                }else{
                    var mesg=str.tip!=undefined&&str.tip!=""?str.tip:"系统异常，稍后重试！"
                    layerFn(mesg);
                }
            })
        }
    })
    $("html").unbind().on("click",".layui-table tr .td1 a",function(){
        var that=this;
        detInformation(that)
    })
    $("body").unbind().on("click",".layui-table tr .td2 a",function(){
        var that=this;
        detInformation(that)
    })
    function detInformation(that){
        var url=$(that).attr("data-num");
        if(url!=undefined&&url!=""){
            window.open(url);
        }
    }
    $(".formContent").scroll(function() {
        var scrolltop=$(this).scrollTop();
        if(scrolltop>0){
            $("#table2 table thead").css({
                "position":"absolute",
                "background":"#f2f2f2",
                "opacity":"1",
                "z-index": 999,
                "top":"0"
            })
        }else{
            $("#table2 table thead").css({
                "position":""

            })
        }
        for (var i = 0; i <  window.widths1.length; i++) {
            var width = $("#table2 table tbody tr:first-child td").eq(i).width() ;
            $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                "width": width+1
            })
        }
    })
    $(window).resize(function () { //当浏览器大小变化时
        //console.log($("#table2 table").width())
        $("#table2 table thead tr").css({
            "width":$("#table2 table").width()

        })
        var heightform=$(".searchContainer").height()-20;


        $(".formContent").css({
            "max-height":heightform*0.85,
            "overflow-y":"scroll"
        });
        if($(".formContent")[0].offsetHeight>(heightform*0.85)){
            $("#pageBar2").css("top",heightform*0.85+20)
        }else{
            $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+40);
        }
        for (var i = 0; i <  window.widths1.length; i++) {
            var width = $("#table2 table tbody tr:first-child td").eq(i).width() ;
            $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                "width": width+1
            })
        }
    });
</script>
</html>